package operations;

import bookList.BookList;

import java.util.Objects;
import java.util.Scanner;

/**
 * The type Find operations.
 *
 * @author CY
 * @date 2022 /08/09 23:49
 */
public class FindOperations implements Operations {
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书！");
        System.out.println("请输入你要查找的图书名：");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            if (Objects.equals(name, bookList.getBooks()[i].getName())) {
                System.out.println("我们找到了这本书，详细信息如下：");
                System.out.println(bookList.getBooks()[i]);
                System.out.println();
                return;
            }
        }
        System.out.println("对不起，没有找到这本书！");
        System.out.println();
    }
}
